package com.jdyfy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jdyfy.entity.Meet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MeetMapper extends BaseMapper<Meet> {

    //一个小时以后的修改会议状态为0
    @Update("UPDATE meets SET status = 0 WHERE meet_time < DATE_ADD(NOW(), INTERVAL 1 HOUR) AND status = 1")
    void updateExpiredMeetings();

    @Update("UPDATE meets SET status = 2 WHERE status = 0")
    void updateOutMeetings();

    @Select("SELECT * FROM meets WHERE status = #{status}")
    List<Meet> getMeetByStatus(@Param("status") Integer status);

    List<String> getExpiredProjectNames();

    @Select("SELECT * FROM meets WHERE project_name = #{projectName}")
    Meet getMeetByProjectName(String projectName);
}
